from nltk.sentiment import SentimentIntensityAnalyzer
import nltk
nltk.download('vader_lexicon')
import pandas as pd

c = 1000

df = pd.read_csv('../data/gpo_final_data/narratives_complete_with_metadata_{0}.csv'.format(c))

sia = SentimentIntensityAnalyzer()
sentences = df['sentence_raw'].drop_duplicates().reset_index()
sentences.drop(columns=['index'], inplace=True)

# Clear some memory
del df

sentiments = [sia.polarity_scores(s) for s in list(sentences.sentence_raw)]
sentences['sentiment_neg'] = [s['neg'] for s in sentiments]
sentences['sentiment_pos'] = [s['pos'] for s in sentiments]
sentences['sentiment_neu'] = [s['neu'] for s in sentiments]
sentences['sentiment_compound'] = [s['compound'] for s in sentiments]
sentences.to_csv('../data/metadata/sentence_sentiments_nltk_vader_{0}.csv'.format(c), index=False)
